#!/bin/bash
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
DIR=$DIR/..
source $DIR/environment

$DIR/check

if [ $? -eq 0 ]; then
    echo "Init templates"
    rm -r charts/agent/templates/*
    mkdir charts/agent/templates/partials
    mkdir charts/agent/templates/hooks
    mkdir charts/agent/templates/crds

    echo "Copy ignore and notes"
    cp helm/templates/.helmignore charts/agent/.helmignore
    cp helm/templates/NOTES.txt charts/agent/templates/NOTES.txt

    echo "Copy crds"
    cp -r helm/templates/agent/crds/* charts/agent/templates/crds/

    echo "Copy hooks"
    cp -r helm/templates/common/hooks/* charts/agent/templates/hooks/

    echo "Copy partials"
    cp -r helm/templates/agent/partials/* charts/agent/templates/partials/
    cp -r helm/templates/common/partials/* charts/agent/templates/partials/

    echo "Copy agent templates"
    cp -r helm/templates/agent/* charts/agent/templates/
    echo "Copy common templates"
    cp -r helm/templates/common/* charts/agent/templates/
fi
